package com.kris.dev3.ObserverModel;

import java.util.Date;

public class People implements MyObserver {

    private String bookName;// 书名
    private Date date;

    private String obName;// 观察者名字
    private MySubject sb;// 发布方

    public People(String name,MySubject aliBook) {// 利用构造器 注册观察者
        this.obName = name;// 观察者名字
        this.sb = aliBook;
        sb.addObserver(this);// 直接调用注册
    }

    @Override
    public void update(String bookName, Date bookDate) {
        this.bookName = bookName;
        this.date = bookDate;
        this.display();
    }

    @Override
    public void display() {
        System.out.println("观察者"+obName);

        System.out.println("书名："+bookName+"书更新时间："+date);
    }
}
